﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace TurtleLib.Simulation
{
  public abstract class ChildPanel : IChildPanel
  {
    protected DragablePanel _parent;
    private Size _renderArea;
    private Point _offset;

    public int X { get { return _offset.X; } set { _offset.X = value; } }
    public int Y { get { return _offset.Y; } set { _offset.Y = value; } }
    public Point Location { get { return _offset; } set { _offset = value; } }

    public int Width { get { return _renderArea.Width; } set { _renderArea.Width = value; } }
    public int Height { get { return _renderArea.Height; } set { _renderArea.Height = value; } }
    public Size Size { get { return _renderArea; } set { _renderArea = value; } }

    public Rectangle Bounds { get { return new Rectangle(Location, Size); } set { Location = value.Location; Size = value.Size; } }

    public DragablePanel Parent { get { return _parent; } }

    public ChildPanel(DragablePanel parent)
    {
      _renderArea = new Size(0, 0);
      _parent = parent;

      _parent.AddChildPanel(this);
    }

    public abstract void Render(Graphics g);
    public abstract Rectangle Resize(DragablePanel.ResizingArgs args);

    public event MouseEventHandler MouseDoubleClick;
    public event MouseEventHandler MouseDown;
    public event MouseEventHandler MouseUp;
    public event MouseEventHandler MouseMove;

    protected void RaiseMouseDoubleClick(object sender, MouseEventArgs e)
    {
      MouseDoubleClick(sender, e);
    }

    protected void RaiseMouseDown(object sender, MouseEventArgs e)
    {
      MouseDown(sender, e);
    }

    protected void RaiseMouseUp(object sender, MouseEventArgs e)
    {
      MouseUp(sender, e);
    }

    protected void RaiseMouseMove(object sender, MouseEventArgs e)
    {
      MouseMove(sender, e);
    }
  }
}
